package com.coke.demo.service.impl;

import com.coke.demo.mapper.RecordMapper;
import com.coke.demo.model.Record;
import com.coke.demo.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 19602
 */
@Service
public class RecordServiceImpl implements RecordService {

    private RecordMapper recordMapper;

    @Autowired
    public void setRecordMapper(RecordMapper recordMapper) {
        this.recordMapper = recordMapper;
    }

    /**
     * 查询所有预约记录
     *
     * @return List<Record>
     */
    @Override
    public List<Record> findAllRecord() {
        return recordMapper.findAllRecord();
    }

    /**
     * 根据id删除订单
     *
     * @param recordid 订单id
     * @return true
     */
    @Override
    public Boolean deleteRecordById(Integer recordid) {
        return recordMapper.deleteRecordById(recordid);
    }

    /**
     * 根据订单id查询订单信息
     *
     * @param recordid 订单id
     * @return Record
     */
    @Override
    public Record findRecordById(Integer recordid) {
        return recordMapper.findRecordById(recordid);
    }

    /**
     * 根据订单id修改订单信息
     *
     * @param record 新的订单信息
     * @return true
     */
    @Override
    public Boolean updateRecordById(Record record) {
        return recordMapper.updateRecordById(record);
    }

    /**
     * 把订单信息存入数据库
     *
     * @param record 订单信息
     * @return true
     */
    @Override
    public Boolean insertRecord(Record record) {
        return recordMapper.insertRecord(record);
    }

    /**
     * 根据用户id查询用户预约记录
     *
     * @param userid :用户id
     * @return List<Record>
     */
    @Override
    public List<Record> findUserRecord(Integer userid) {
        return recordMapper.findUserRecord(userid);
    }

    /**
     * 统计预约记录数量
     *
     * @return Integer
     */
    @Override
    public Integer countRecord() {
        return recordMapper.countRecord();
    }

    /**
     * 查询所有订单的预约时间
     *
     * @return List<String>
     */
    @Override
    public List<String> findAllRecordBookTime() {
        return recordMapper.findAllRecordBookTime();
    }

    /**
     * 查询未开始的预约订单
     *
     * @return List<String>
     */
    @Override
    public List<Record> findSomeBookTime() {
        return recordMapper.findSomeBookTime();
    }

    /**
     * 根据订单id更新订单状态
     *
     * @param id    订单id
     * @param state
     * @return true
     */
    @Override
    public Boolean updateStateById(Integer id, String state) {
        return recordMapper.updateStateById(id, state);
    }

    /**
     * 根据实验室名称模糊查询订单信息
     *
     * @param labname 实验室名称
     * @return Record
     */
    @Override
    public ArrayList<Record> queryRecordByLabName(String labname) {
        return recordMapper.queryRecordByLabName(labname);
    }

}
